package entity

type AuthRule struct {
	Name string `gorm:"type:varchar(64);index"`
	Data []byte `gorm:"type:blob"`
	CreatedAt int64
	UpdatedAt int64
}

func (t *AuthRule) TableName() string {
	return "auth_rule"
}

type AuthItem struct {
	Name string `gorm:"type:varchar(64);primary_key"`
	Type int8 `gorm:"index"`
	Description string  `gorm:"text"`
	// AuthRules       AuthRule `gorm:"ForeignKey:RuleName;AssociationForeignKey:Name"`
	RuleName string  `gorm:"type:varchar(64);index"`
	Data []byte `gorm:"type:blob"`
	CreatedAt int64
	UpdatedAt int64
}

func (t *AuthItem) TableName() string {
	return "auth_item"
}

type AuthItemChild struct {
	// AuthParent       AuthItem `gorm:"ForeignKey:Parent;AssociationForeignKey:Name"`
	Parent string `gorm:"type:varchar(64);primary_key"`
	// AuthChild      AuthItem `gorm:"ForeignKey:Child;AssociationForeignKey:Name"`
	Child string `gorm:"type:varchar(64);primary_key;index"`
}

func (t *AuthItemChild) TableName() string {
	return "auth_item_child"
}

type AuthAssignment struct {
	// AuthItem        AuthItem `gorm:"ForeignKey:ItemName;AssociationForeignKey:Name"`
	ItemName string `gorm:"type:varchar(64);primary_key"`
	UserId string `gorm:"type:varchar(64);primary_key;index"`
	CreatedAt int64
}

func (t *AuthAssignment) TableName() string {
	return "auth_assignment"
}
